﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.ComponentModel;
using Doo.Controls;

namespace Doo.DataSource
{
    /// <summary>
    /// 数据源的基类
    /// 数据源提供一个统一的数据获取和更改接口
    /// </summary>
    [ParseChildren(true, "SelectParameters")]
    public abstract class DataSourceBase : Doo.WebUI.DooControl
    {
        const string _ScriptName = "Doo.WebUI.DataSource.base.script.js";

        /// <summary>
        /// 选择参数，指定这些以获取数据
        /// </summary>
        [Category("Behavior"),
        Description("选择参数"),
        DesignerSerializationVisibility(
        DesignerSerializationVisibility.Content),
        PersistenceMode(PersistenceMode.InnerDefaultProperty)
        ]
        public virtual List<Parameter> SelectParameters { get; set; }

        /// <summary>
        /// 开发人员使用，确定是否支持版本号
        /// </summary>
        protected virtual bool SupportVersion
        {
            get { return true; }
        }

        protected override void SetScriptReferences(List<ScriptReference> reference)
        {
            base.SetScriptReferences(reference);
            reference.Add(new ScriptReference(_ScriptName, this.GetType().Assembly.FullName));
        }
    }
}
